#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>

#include "heapq.h"

int my_cmp_fn(const void *a, const void *b) {
    if (*(int*)a > *(int*)b) {
        return 1;
    }
    else if (*(int*)a < *(int*)b) {
        return -1;
    }
    else return 0;
}

// 测试函数
int main() {
    heapq h;
    heapq_init(&h, sizeof(int), my_cmp_fn, NULL, NULL, NULL);
    for (int i = 20; i >= 0; i--)
    {
        heapq_push(&h, &i);
    }
    for (int i = 0; i < 20; i++)
    {
        printf("%d ", *(int*)heapq_top(&h));
        heapq_pop(&h);
        printf("|%d ", h.vec.size);
    }
    heapq_pop(&h);

    heapq_free(&h);

    printf("\nAll tests for heapq passed successfully.");
    return 0;
}